/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;

/**
 * <p>Project: javase202202 - Format4
 * <p>Powered by Lisi On 2022-05-30 10:05:36
 * <p>Created by IntelliJ IDEA
 *

 * @version 1.0
 * @since 17
 */
public class Format4 {
    public static void main(String[] args) {
        //Locale.setDefault(Locale.US);
        //格式化数字
        //整数
        int i = 80;
        System.out.println(i);
        System.out.printf("%06d%n",i);
        System.out.printf("%.2f%n",(float)i);
        //NumberFormat ci = DecimalFormat.getCurrencyInstance();
        //System.out.println(ci.format(i));

        NumberFormat n1 = DecimalFormat.getCurrencyInstance(Locale.CHINA);
        NumberFormat n2 = DecimalFormat.getCurrencyInstance(Locale.US);
        System.out.println(n1.format(i));
        System.out.println(n2.format(i));

        NumberFormat nf = DecimalFormat.getPercentInstance();
        System.out.println(nf.format(.02345));

        //小数
        System.out.printf("%.3f  ￥%,.2f%n",123456.1234f,123345456.1234f);

        DecimalFormat df = new DecimalFormat("#,###.####");
        System.out.println(df.format(1234246.55555));

    }
}
